import createError from './createError'

/**
 * 根据 response 的状态执行 resolve 或者 reject
 * @param resolve 
 * @param reject 
 * @param response 
 */
export default function settle(resolve, reject, response) {
    var validateStatus = response.config.validateStatus;
    if (!response.status || !validateStatus || validateStatus(response.status)) {
      resolve(response);
    } else {
      reject(createError(
        'Request failed with status code ' + response.status,
        response.config,
        null,
        response.request,
        response
      ));
    }
  };